package com.liwei.lwmail.seckill.scheduled;

import lombok.extern.slf4j.Slf4j;
import org.springframework.scheduling.annotation.Async;
import org.springframework.scheduling.annotation.EnableAsync;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;


@Slf4j
@Component
public class HelloScheduled {

    /**
     *1、cron表达式
     *2、Spring中1-7代表周一到周日
     *3、定时任务不应该阻塞
     */
    @Async
    @Scheduled(cron = "* * * * * 7")
    public void hello() throws InterruptedException {
        log.info("hello...");
        Thread.sleep(3000);//会造成定时任务阻塞
    }
}
